export class SingletonEventEmitter {
	eventMap: Record<string, Function>

	constructor() {
		this.eventMap = {}
	}

	on = (messageType: string | number, fn: Function) => {
		this.eventMap[messageType] = fn
	}

	trigger = (messageType: string | number, ...json: any[]) => {
		this.eventMap[messageType]?.(...json)
	}

	off = (messageType: string | number) => {
		if (messageType == null) {
			this.eventMap = {}
		} else {
			this.eventMap[messageType] = null
		}
	}
}
